#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<initializer_list>
using namespace std;

class Solution {
public:
    int gitsum(int n)
    {
        int sum = 0;
        while (n)
        {
            int tmp = n % 10;
            sum += tmp * tmp;
            n /= 10;
        }
        return sum;
    }

    bool isHappy(int n) {
        int slow = n, fast = n;
        do
        {
            slow = gitsum(slow);
            fast = gitsum(fast);
            fast = gitsum(fast);
            if (fast == 1 || slow == 1)
                return true;
        } while (slow != fast);
        return false;
    }

    int halveArray(vector<int>& nums) {
        priority_queue<double> heap;
        double sum = 0.0;
        for (auto e : nums)
        {
            sum += e;
            heap.push(e);
        }
        sum /= 2.0;
        int count = 0;
        while (sum > 0)
        {
            double t = heap.top() / 2;
            heap.pop();
            sum -= t;
            heap.push(t);
            ++count;
        }
        return count;
    }
};

int main()
{
    vector<int> v = { 58,23 };
    Solution s;
    s.halveArray(v);
}